<extend name="Layout:layout_list" />
<block name="body_content_block">
    <table id="main_grid" class="easyui-datagrid" data-url="{:AddonU('Extension/get_seat_list_json')}"></table>
    <div id="tb" style="padding:2px 5px;">
        <div style="margin-bottom: 5px; border-bottom:solid 1px #dddddd;">
            <if condition="equal_permission_name('编辑工号',$loginData['role_id'])">
                <a href="{:AddonU('Extension/seat_edit','id=varkey')}" class="easyui-linkbutton lnk_grid_edit" iconCls="icon-edit" plain="true">编辑</a>
            </if>
            <if condition="$loginData['USER_KEY'] eq 'TTF'">
                <a href="{:AddonU('Extension/seat_batch_edit','id=varkey')}" class="easyui-linkbutton lnk_grid_edit lnk_batch_edit" iconCls="icon-card" plain="true" data-window-mode="single">快速编辑</a>
            </if>
            <if condition="equal_permission_name('重置工号密码',$loginData['role_id'])">
                <a href="{:AddonU('Extension/seat_password_reset','id=varkey')}" class="easyui-linkbutton lnk_grid_remove" iconCls="icon-resetpwd" plain="true" data-confirm-message="您确定要将密码重置为123456吗?">重置密码</a>
            </if>
            <a href="#" class="easyui-linkbutton lnk_grid_search" iconCls="icon-search" plain="true">搜索</a>
        </div>
    </div>
    <!--隐藏区域-->
    <div style="display:none">
        <!--表格查询对话框-->
        <div id="dlg_search" style="padding:10px">
            <form method="get" action="{:AddonU('Extension/get_seat_list_json')}" data-export-url="{:AddonU('Extension/seat_export')}">
                分机号：<input type="text" name="userName" class="easyui-textbox" title="分机号,多个以英文逗号隔开" />(<a href="###" title="分机号,多个以英文逗号隔开">?</a>)
                队列号：<input type="text" name="teamNumber" id="teamNumber" class="easyui-combobox" data-url="{:AddonU('Queue/get_queue_json')}" />
                <if condition="$isSuperAdmin">
                    租户：<input type="text" name="siteID" id="siteID" class="easyui-combobox" data-url="{:AddonU('Admin/get_admin_json')}" />
                    <else/>
                    <input type="hidden" name="siteID" value="{$loginData.siteID}"/>
                </if>
            </form>
        </div>
        <!--/表格查询对话框-->
    </div>
    <!--/隐藏区域-->
</block>
<block name="body_after_block">
    <script type="text/javascript">
        // 页面初始化
        var curd_grid = CurdGrid.newInstance();
        curd_grid.before_search_dialog = function () {
            $('#siteID').combobox({url: $('#siteID').data('url'), valueField: 'id', textField: 'text'});
            $('#teamNumber').combobox({url: $('#teamNumber').data('url'), valueField: 'id', textField: 'text'});
        }
        curd_grid.config({
            title: '分机管理',
            toolbar: '#tb',
            fitColumns: true,
            showFooter: true,
            columns: [[
                    {field: 'ck', checkbox: true},
                    {title: "租户ID", field: "siteIDText", sortable: true},
                    {title: "工号", field: "userName", sortable: true},
                    {title: "姓名", field: "personalName", sortable: true},
                    {title: "分机号", field: "extensionNumber", sortable: true},
                    {title: "队列号", field: "teamNumber", sortable: true},
                    {title: "班长模式", field: "ctiModelText", sortable: true},
                    {title: "状态", field: "stateText", sortable: true},
                    {title: "创建时间", field: "createdTime", sortable: true},
                    {title: "编号", field: "id", hidden: true},
                ]],
            onDblClickRow: function (index, row) {
                var $a = $('.lnk_batch_edit');
                if (!$a[0]) {
                    $a = $(".lnk_grid_edit");
                }
                if ($a[0]) {
                    curd_grid.open_iframe_dialog({title: curd_grid._replace_title_vars($a, row), icon: $a.attr('iconCls'), url: curd_grid._replace_var_keys($a.attr('href'), row, $a.data('varReplaces'))});
                }
            }
        });
        curd_grid.init();
    </script>
</block>